package com.sample.transaction.seata.sys.controller;

import cn.hutool.core.util.RandomUtil;
import com.sample.transaction.seata.sys.entity.Storage;
import com.sample.transaction.seata.sys.repo.StorageRepository;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/storage")
@RequiredArgsConstructor
public class StorageController {

    private final StorageRepository orderRepository;

    // http://localhost:4002/storage/insert
    @GetMapping("insert")
    public Boolean getUserById(){
        Storage order = new Storage();
        order.setCommodityCode(RandomUtil.randomString(10));
        order.setCount(RandomUtil.randomInt(5));
        orderRepository.save(order);
        return Boolean.TRUE;
    }

}
